package com.kaifamiao.convert;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.util.Date;

/**
 * java.time.LocalDateTime ===> java.util.Date
 * 1、java.util.Date类的实例表示某个瞬间(精确到毫秒)
 * 2、java.time.LocalDate类的实例表示"本地日期"(只包含年、月、日)
 * 3、java.time.LocalTime类的实例表示"本地时间"(只包含时、分、秒、纳秒)
 * 4、java.time.LocalDateTime类的实例表示"本地日期时间"
 */
public class ToDateTest1 {

	public static void main(String[] args) {
		
		LocalDate date = LocalDate.now();
		LocalTime time = LocalTime.now();
		LocalDateTime datetime = LocalDateTime.of(date, time);
		
		// ZoneOffset offset = ZoneOffset.ofHours( 8 ) ;
		ZoneOffset offset = ZoneOffset.of( "+08:00" );
		System.out.println( offset );
		
		Instant instant = datetime.toInstant( offset ) ;
		
		Date target = Date.from( instant ) ; 
		
		System.out.println( target );

	}

}
